﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Utility.DBUtility.ORM.EntityAttribute
{
    /// <summary>
    /// 数据库字段属性标签
    /// </summary>
    [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field)]
    public class DbColumnAttribute : Attribute
    {
        /// <summary>
        /// 数据库字段属性标签
        /// </summary>
        /// <param name="columnName">数据库字段名称</param>
        /// <param name="isPrimary">否主键</param>
        /// <param name="length">数据库字段长度, 0表示不设定长度</param>
        /// <param name="dbType">数据库类型</param>
        /// <param name="ignore">忽略该字段</param>
        public DbColumnAttribute(string columnName = ""
                                , bool isPrimary = false                                
                                , Utility.Data.DbClient.DBType dbType = Utility.Data.DbClient.DBType.Oracle_Varchar2
                                , int length = 0
                                , bool ignore= false)
        {
            ColumnName = columnName;
            IsPrimary = isPrimary;
            Length = length;
            DbType = dbType;
            Ignore = ignore;
        }
        /// <summary>
        /// 字段属性名称
        /// </summary>
        public string PropertyName { get; set; }
        /// <summary>
        /// 数据库字段名称
        /// </summary>
        public string ColumnName { get; set; }
        /// <summary>
        /// 是否主键
        /// </summary>
        public bool IsPrimary { get; set; }
        /// <summary>
        /// 数据库字段长度, 0表示不设定长度
        /// </summary>
        public int Length { get; set; }
        /// <summary>
        /// 数据库类型
        /// </summary>
        public Utility.Data.DbClient.DBType DbType { get; set; }
        /// <summary>
        /// 忽略自动映射该字段
        /// </summary>
        public bool Ignore { get; set; }
    }
}
